﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Http;
using System.Web.Security;
using System.Web.SessionState;
using He.Common;
using He.Web.App_Start;

namespace He.Web
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
        public override string GetVaryByCustomString(HttpContext context, string arg)
        {
            string ucCacheKey = "ucCacheFlag";
            if (arg == ucCacheKey)
            {
                Object flag = CacheHelper.Get(ucCacheKey);
                if (flag == null)
                {
                    flag = DateTime.Now.Ticks.ToString();
                    CacheHelper.Add(ucCacheKey, flag, 360000);
                }
                return flag.ToString();
            }

            return base.GetVaryByCustomString(context, arg);
        }
    }
}